<template>
	<view>
		<view class="list">
			<view class="item" @tap="tapitem(i)"  :style="{marginTop:i.top?i.top:'1rpx'}" v-for="i in config">
				<view class="view">{{i.title}}</view>
				<view class="text" v-if="data[i.key]">{{data[i.key]}}</view>
				<view class="text" v-if="!(data[i.key])">空</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			//配置信息,格式[{title:'用户名',key:'username'}]
			config: {
				type: Array,
				default: []
			},
			data: {
				type: Object,
				default: {}
			}
		},
		data() {
			return {
				tapitem(info){
					this.$emit('change',info)
				},
			};
		}
	}
</script>

<style lang="scss" scoped>
	.list {
		display: flex;
		flex-direction: column;
		background-color: #f2f2f2;
	}

	.item {
		display: flex;
		align-items: center;
		background-color: #fff;
		justify-content: space-between;
		flex-wrap: wrap;
		padding: 0 30rpx;
		&:active{
			background-color: #f2f2f2;
		}
		
		.view {
			padding: 30rpx 0;
			font-size: 14px;
			flex: 1;
			color: #333333;
		}

		.text {
			display: -webkit-box;
			-webkit-box-orient: vertical;
			-webkit-line-clamp: 0;
			overflow: hidden;
			font-size: 14px;
			color: #999;
		}
	}
</style>
